package com.settlement.system.service.impl;

import com.settlement.system.mapper.TblAcsUserFileMapper;
import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.model.entity.common.TblAcsUserFile;
import com.settlement.system.service.ITblAcsUserFileService;
import org.springframework.stereotype.Service;
import com.settlement.system.mapper.BaseMapper;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * 稽核平台用户文件 服务实现类
 * @author Ximi
 * @since 2020-05-22
 */
@Service
public class TblAcsUserFileServiceImpl extends BaseServiceImpl implements ITblAcsUserFileService {

    @Resource
    private TblAcsUserFileMapper tblAcsUserFileMapper;

    @Override
    public BaseMapper init() {
        return tblAcsUserFileMapper;
    }

    /**
     * 批量新增
     * @param list
     * @throws ServiceException
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void batchAdd(List<TblAcsUserFile> list) throws ServiceException {
        try {
            for(TblAcsUserFile userFile:list){
                tblAcsUserFileMapper.insert(userFile);
            }
        } catch (Exception ex){
            throw new ServiceException(ex);
        }
    }

    /**
     * 通过id获取数据
     * @param id
     * @return
     * @throws ServiceException
     */
    @Override
    public TblAcsUserFile getUserFileById(String id) throws ServiceException {
        try {
            return tblAcsUserFileMapper.getUserFileById(id);
        } catch (Exception ex){
            throw new ServiceException(ex);
        }
    }
}

